#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
using namespace std;
#include<stack>
#include<vector>


class Solution 
{
public:
    int evalRPN(vector<string>& tokens) 
    {
        stack<int> stk;
        int n = tokens.size();
        for (int i = 0; i < n; i++) 
        {
            string& token = tokens[i];
            if (isNumber(token)) 
            {
                stk.push(atoi(token.c_str()));
            }
            else 
            {
                int num2 = stk.top();
                stk.pop();
                int num1 = stk.top();
                stk.pop();
                switch (token[0]) 
                {
                case '+':
                    stk.push(num1 + num2);
                    break;
                case '-':
                    stk.push(num1 - num2);
                    break;
                case '*':
                    stk.push(num1 * num2);
                    break;
                case '/':
                    stk.push(num1 / num2);
                    break;
                }
            }
        }
        return stk.top();
    }

    bool isNumber(string& token) 
    {
        return !(token == "+" || token == "-" || token == "*" || token == "/");
    }
};

int main()
{
    Solution S;
    vector<string> str = { "2","1","+","3","*" };
    cout << S.evalRPN(str) << endl;
    return 0;
}